function ${systemCode}Business() {
    this.formValid = new FormValidBusiness();
    this.mainTableNames;
    this.mainTableModel;
    this.mainTable;
    this.jsonReader;
    this.mainTableUrl="${qryUrl}.do";//修改主表url
<#if (popupTableUrl)??>
    this.mainTableSelectedHeadId;
    this.lineTable;
    this.lineTableNames;
    this.lineTableModel;
    this.lineTableUrl = "${popupTableUrl}.do"; //行数据查询url
</#if>
}

${systemCode}Business.prototype = {
    ready: function () {
        initXInput();//初始化input输入框的快速删除按钮
        showOrHide();//初始化查询面板隐藏功能
        //this.initSessoin();//初始化session数据
        //this.initMainTableExportButton(); //初始化导出按钮
        this.initData();//初始化静态变量
        this.initComponent()//初始化组件
        this.initMainTable();//初始化主表
        this.initBtn();//初始化按钮
    },
    initBtn: function () {
        var This = this;
        $("#qryBtn").click(function () {
            var params = This.formValid.getFromData($("#mainTableQryForm"));
            This.validateQryParams(params);
            This.mainTable.reload({
                gridParam: params,
                "clearSelect": true,
                url: cp + This.mainTableUrl
            });
        });
<#if (popupTableUrl)??>
        $("#qryLineTableBtn").click(function () {
            var params = This.formValid.getFromData($("#lineTableQryForm"));
            This.lineTable.reload({
                gridParam: params,
                "clearSelect": true,  //清楚已勾选数据
                url: cp + This.lineTableUrl
            });
        });
</#if>
    },
    //校验Json数据有效性
    validateQryParams:function(params){
        //if(params["CREATION_DATE_END"]<params["CREATION_DATE_BEGIN"]){
        //    layer.msg("开始时间必须小于结束时间", {icon: 3, time: 2500});
        //    throw SyntaxError();
        //}
        //校验是否存在，不存在则抛异常
        //validateRequired(params,['CREATION_DATE_BEGIN','CREATION_DATE_END','STORE_CODE'],['开始时间必填','结束时间必填','门店必选']);
    },
    initMainTableExportButton(){
        var This=this;
        var sFuns="${systemCode}";
        var sModel="REPORT";
        selectAllHover.build({
            $dom: $("#downloadBtn").parent(),
            btn: ["已勾选", "全部"],
            func: [function () {
                var data = This.mainTable.getSelectData();
                if (data.length <= 0) {
                    layer.msg("请勾选要操作的数据", {icon: 8, time: 1000});
                    return;
                }
                var layerIndex = layer.confirm("是否下载已勾选数据", function () {
                    layer.close(layerIndex);
                    simpleDownload.download({
                        //multiHeader: true,   //多级表头
                        table: This.mainTable,
                        data: data,
                        downloadParam: {
                            S_FUNS: sFuns,
                            S_MODEL: sModel,
                        }
                    });
                    }, function () {
                        });
                }, function () {
                    var layerIndex = layer.confirm("是否下载所有数据", function () {
                        layer.close(layerIndex);
                        var param = This.formValid.getFromData($("#mainTableQryForm"));
                        This.validateQryParams(param);
                        param["S_MODEL"] = sModel;
                        param["S_FUNS"] = sFuns;
                        simpleDownload.download({
                            //multiHeader: true,  //多级表头
                            table: This.mainTable,
                            downloadParam: param,
                        });
                     }, function () {
                         });
            }]
        });
    },
    initSessoin: function () {
        var This = this;
        var ajaxParam = {};
        var myDate = new Date();
        ajaxParam["url"] = cp + "mgt/common/getSession.do";
        ajaxParam["param"] = {};
        ajaxParam["callback"] = function (data) {

        };
        ajaxParam["error"] = function (data) {
            layer.msg("操作失败", {icon: 2, time: 1000});
        };
        ajaxParam["ajaxError"] = function () {
            layer.msg("系统繁忙，操作失败", {icon: 2, time: 1000});
        };
        myAjax.ajax(ajaxParam);
    },
    initComponent:function(){
        //初始化日期组件样例
/*        laydate.render({
            elem : ".CREATION_DATE_FR",
            format: 'yyyy-MM-dd'
        });*/

    },
    initData: function () {
        var This = this;
        this.jsonReader = {
            rows: "o_data.data",   // json中代表实际模型数据的入口
            page: "o_data.currentPageNo",   // json中代表当前页码的数据
            total: "o_data.totalPageCount", // json中代表页码总数的数据
            records: "o_data.totalCount", // json中代表数据行总数的数据
            pageSize: "o_data.pageSize"
        };
        this.mainTableNames = [
<#if (popupTableUrl)??>
        {
            index: "opt", align: "center", width: 60, formatter: function (val, model, data, $td) {
                return "<a class='operationBtn viewRow'><i class='iconDetail'></i>关联</a>";
            }
        },
</#if>
<#list sqlColumnList as po>
            {cellvalue : "${po.columnText}"},
</#list>
        ];
        this.mainTableModel = [
<#list sqlColumnList as po>
            {index: "${po.columnName}", align: "center", width: 200},
</#list>
        ];

<#if (popupTableUrl)??>
//TODO 生成模板后待修改
        this.lineTableNames = [
            {cellvalue: "商品编码"},
        ];
        this.lineTableModel = [
            {index: "ITEM_NO", align: "center", width: 200},
            {index: "ITEM_ID", hidden: true},
        ];
</#if>
    },
    initMainTable: function () {
        var This = this;
        this.mainTable = dataGrid.createTable({
            $dom: $("#dataGrid"),
            gridParam: {},
            lazyLoading:true,
            hideFlag:true,//自定义列，多级表头的需要隐藏
            saveName:"${systemCode}Business",//多级表头的需要隐藏
            colNames: This.mainTableNames,
            colModel: This.mainTableModel,
            //primaryKeys:"",
            multiselect: true,//复选框
            pageParam: {
                $dom: $("#page"),
                pageSizeSel: [100,200,500,1000]
            },
            jsonReader: This.jsonReader,
            loadComplete: function (tb) {
                var $table = tb.get$Table();
<#if (popupTableUrl)??>

                $table.find("tbody tr a.viewRow").unbind().click(function () {
                    var data = tb.getRowDataTdBy$tr($(this).closest("tr"));
                    This.layerIndex_lineTable = mylayer.open({
                        title: '<i class="iconlayer iconAddHD"></i>关联',
                        type: 1,
                        closeBtn: 1,
                        maxmin: true,
                        content: $(".lineViewDiv"),
                        success: function ($dom) {
                            $dom.find(".lineViewDiv").css({"height": "100%", "position": "relative"});
                            $dom.find(".emouseUi-layerContent").css({"height": "80%", "overflow": "auto"});
                            $dom.find(".mylayerBtnGrap .btnCancel").unbind().click(function () {
                                layer.close(This.layerIndex_lineTable);
                            });
                        },
                        end: function () {
                        }
                    });
                    layer.full(This.layerIndex_lineTable);
                    //This.mainTableSelectedHeadId = data["LINE_ID"];
                    This.initLineTable();
                    $("#qryLineTableBtn").trigger("click");
                });
</#if>
            }
        });
    },
<#if (popupTableUrl)??>
    initLineTable: function () {
        var This = this;
        setPositionBottomZero($(".lineViewDiv .emouseUi-layerContent"), 135);
        var tableHeight = setPositionBottomZero($("#dataGrid_view"), 154) + $("#dataGrid_view").parent().position().top;
        this.lineTable = dataGrid.createTable({
            $dom: $("#dataGrid_view"),
            lazyLoading: true,
            height: tableHeight,
            selfDefineHeight: true,
            //multiselect: true,//复选框
            //primaryKeys: "ITEM_ID",
            colNames: This.lineTableNames,
            colModel: This.lineTableModel,
            pageParam: {
                $dom: $("#page_view"),
                pageSizeSel: [100, 200, 500, 1000]
            },
            jsonReader: This.jsonReader,
            loadComplete: function (tb) {
                var $table = tb.get$Table();
                //**---表格加载完毕后新增一行总计。如果当前是第一页且数据量小于pagesize，则当页统计，否则后台sql统计
                //var params = This.formValid.getFromData($("#mainTableQryForm"));
                //var addRow={"ORG_NAME":"统计：","TMY":0,"TQUANTITY":0,"TSY":0,"YMY":0,"YQUANTITY":0,"YSY":0};
                //var currentPageSize=$("#mainTableQryForm .searchPage select").val();
                //sumAndCountTable(This.mainTable,cp+this.mainTableUrl,params,addRow,currentPageSize);
                //**---增加总计行代码结束

            }
        });
    },
</#if>

}